package edu.ntu.cloudroid.model.function.stats;

import java.util.List;

import edu.ntu.cloudroid.model.data.AbstractData;
import edu.ntu.cloudroid.model.data.StatData;

public class MinFunction implements IDataStats{

	@Override
	public Object getStats(List<AbstractData> data, Object params) {
		//param here is the column id
		int colIdx = ((Integer)params).intValue();
		if (data.size()==0)
			return new StatData(-1);
		
		AbstractData min = data.get(0);
		for (AbstractData ad : data)
			if (ad.compareTo(min, colIdx)==-1)
				min = ad;
		return min;
	}

}
